package co.yixiang.modules.security.rest;

import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.config.ValueStyleProperty;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @program: yshop
 * @description: bb
 * @author: zhuang.huan
 * @create: 2021-07-04 15:23
 **/
@Slf4j
@RestController
@RequestMapping("/apollo")
@Api(tags = "apollo：测试接口")
public class ValuePropertyController {


    @Autowired
    private ValueStyleProperty keyProperty;

    @Value("${server.port}")
    private String port;

    @Value("${apollo.bootstrap.namespaces:'application'}")
    private String namespaces;

    @AnonymousAccess
    @ApiOperation("测试apollo")
    @GetMapping(value = "/get")
    public Map<String, Object> getProperty() {
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("port", port);
        map.put("namespaces", namespaces);
        map.put("demoKey1", keyProperty.getDemoKey1());
        map.put("demoKey2", keyProperty.getDemoKey2());
        return map;
    }
}
